package com.example.data.permission.mp.redis;

import com.example.data.permission.dao.UserMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.RedisTemplate;


/**
 * Created by TD on 2021/7/21
 * 项目启动后，存储所有用户的数据权限信息，门店数据
 */
@Slf4j
@Configuration
public class LoginWithStorePermission {

    @Autowired
    RedisTemplate<String, Object> redisTemplate;
    @Autowired
    UserMapper userMapper;
    public static final String REDIS_PREFIX = "jxc:";

/*    @Async
    @Order
    @SneakyThrows
    @EventListener(WebServerInitializedEvent.class)
    public void afterStart(WebServerInitializedEvent event) {
        // 1.  查询用户信息、角色、数据权限数据
        log.info("===========模拟登陆===========");
        UserInfoDTO userInfoDTO = userMapper.getUserInfoByUserName("mrguo");
        log.info("===========用户信息===========");
        log.info(userInfoDTO.toString());
        log.info("===========用户信息缓存入Redis===========");
        redisTemplate.opsForValue().set(REDIS_PREFIX + userInfoDTO.getUsername(), userInfoDTO);
    }*/
}

